
package stcu.robjects;

import com.nvlled.route.*;
import stcu.Account;

public class Login extends RoutedObject {

    public static String OK = "ok";
    public static String INVALID_USER = "Invalid user";
    public static String LOGGED_IN = "Already logged in";

    private String idNumber;

    // TODO: change idNumber to idNumber
    public Login(String idNumber) {
        this.idNumber = idNumber;
    }

    public String getIDNumber() {
        return idNumber;
    }

    public static class Status extends RoutedObject {
        private String code;
        private String idNumber;
        private String lastname;
        private String firstname;

        public Status(String code, Account account) {
            this.code = code;
            this.idNumber = account.getIDNumber();
            this.firstname = account.getFirstName();
            this.lastname = account.getLastName();
        }
        public Status(String code) {
            this(code, new Account("-1"));
        }

        public boolean failed() {
            return !isOK();
        }

        public String getCode() {
            return code;
        }

        public String getIDNumber() {
            return idNumber;
        }

        public Account getAccount() {
            return new Account(idNumber, lastname, firstname);
        }

        public String getName() {
            return firstname + " " + lastname;
        }

        public boolean isOK() {
            return code.equals(Login.OK);
        }
    }
}

